<?
/*
foreach ($_skin["trail"] as $k=>$e)
	if ($e["module"] == "project" && strcmp($e["value"],intval($e["value"]))==0)
		$pid = $_SESSION["project_id"] = $e["value"];
if (!$pid) $pid = $_SESSION["project_id"];
if ($pid) {
	$pe = $db->query1("select * from project where id = ".$db->sqlint($pid));
	}
	*/
?>
<html>
<head>
<title><?=$GLOBALS["config"]["title"];?></title>
<style type="text/css">
<? 
$css = $_SESSION["user"]["css"];
if (!$css) $css = "default.css";
$css = str_replace(array("..","/"),array("_","_"),$css); #NOTE: silly security 
readfile(dirname(__FILE__)."/$css");
?>
</style>
</head>
<body>
<div class='logo'>
<?=$GLOBALS["config"]["title"];?>
</div>
<div class='tabs'>
<?
global $myurl,$_skin,$db,$topurl;

$tabs = array();

$tabs[] = array(
	"link"=>"$myurl/users/",
	"title"=>"Users",
	"path"=>"users/",
	"group"=>"admin_users",
	);
		
$tabs[] = array(
	"link"=>"$myurl/groups/",
	"title"=>"Groups",
	"path"=>"groups/",
	"group"=>"admin_groups",
	);

$tabs[] = array(
	"link"=>"$myurl/skins/",
	"title"=>"Skins",
	"path"=>"skins/",
	"group"=>"admin_skins",
	);
	
$tabs[] = array(
	"link"=>"$myurl/modules/",
	"title"=>"Modules",
	"path"=>"modules/",
	"group"=>"admin_modules",
	);

$tabs[] = array(
	"link"=>"$myurl/folders/",
	"title"=>"Folders",
	"path"=>"folders/",
	"group"=>"admin_folders",
	);
	
$tabs[] = array(
	"link"=>"$myurl/pages/0/",
	"title"=>"Top",
	"path"=>"pages/0/",
	"group"=>"admin_top",
	);
	
$tabs[] = array(
	"link"=>"$myurl/newss/",
	"title"=>"News",
	"path"=>"newss/",
	);

$tabs[] = array(
	"link"=>"$myurl/pages/1/",
	"title"=>"Categories",
	"path"=>"pages/1/",
	#"group"=>"admin_projects",
	);

		
$tabs[] = array(
	"link"=>"$myurl/projects/",
	"title"=>"Projects",
	"path"=>"projects/",
	#"group"=>"admin_projects",
	);


$tabs[] = array(
	"link"=>"$myurl/docscomments/",
	"title"=>"Docs Comments",
	"path"=>"docscomments/",
	#"group"=>"admin_projects",
	);
	
		
$tabs[] = array(
	"link"=>"$topurl/login.php/logout.php",
	"title"=>"Sign Out",
	"align"=>"right",
	"target"=>"_top",
	);
	
$user = $_SESSION["user"];
foreach ($tabs as $k=>$e) {
	$ok = 1;
	if ($e["group"] && !in_array($e["group"],$user["groups"]))
		unset($tabs[$k]);
	}
	
#echo "<pre>";print_r($_skin["trail"]);echo "</pre>";
#$module = $_skin["trail"][0]["module"];

$path = "";
foreach ($_skin["trail"] as $k=>$e) if ($k!=0) 
	$path.="{$e["value"]}/";
$path .= $GLOBALS["fname"];

$cur = -1;
$len = 0;
foreach ($tabs as $k=>$e) {
	$pos = strpos($path,$e["path"]);
	if ($pos === 0 & ($l=strlen($e["path"])) > $len)
		{ $cur = $k; $len = $l; }
	}


$align = "";
echo "<table width='100%'><tr>";
$align="left";
echo "<td align='$align' class='c'><table><tr>";
$n = 0;
foreach ($tabs as $k=>$e) {
	if ($e["align"]!="" & $e["align"] != $align) {
		echo "</table>";
		$align = $e["align"];
		echo "<td align='$align' class='c'><table><tr>";
		$n=0;
		}

	$c = ($cur == $k)?'s':'';
	
	if ($n) echo "<td class='l'>|";
	$target = $e["target"]?"target='{$e["target"]}'":"";
	echo "<td class='$c'><a href='{$e["link"]}' class='$c' $target>{$e["title"]}</a>";
	$n++;
	}
echo "</table>";
echo "</table>";

$trail = "";
if ($_skin["trail"]) {
foreach ($_skin["trail"] as $te) {
	list($uri,$title) = array($te["uri"],$te["title"]); 
	
	if ($uri != "" && $title != "")
		$trail.= "<a href='$uri'>$title</a> &gt; "; 
	elseif ($title != "") 
		$trail.= "$title &gt; ";
	}
}

?>
</div>
<div class='shadow' style='background: url("shadow.gif");'><img src="spacer.gif" width=1 height=6></div>
<div class='content'>
<table cellpadding=0 cellspacing=0 border=0 width='100%'>
<tr><td valign=top><h1><?=$trail;?></h1><div>%%</div>
</table>
</div>

<div class='copyright' align='center'>
Copyright &copy; <?=date("Y");?> Lance Technologies LLC.  All Rights Reserved.
</div>

</body>
</html>
